/******************************************************************************
 cnome: A C++ source "genes" discover. :-)

 See more details at:

   http://www.codeplex.com/cnome

 The original author site is at: http://www.alemosbarbosa.com/

 Copyright (c) 2008-2010 Alexandre Lemos Barbosa.
 Distributed under the MIT License. (See accompanying file LICENSE-MIT.txt 
 or at http://www.codeplex.com/cnome/license)
 ******************************************************************************/

#ifndef DIRECTIVE_SSS_H
#define DIRECTIVE_SSS_H

#include "directive_base.h"
#include "variables.h"

namespace cnome { namespace directive {

    struct sss_parser_gen;

    template <typename ParserT>
    struct sss
    :   public boost::spirit::classic::unary<ParserT, boost::spirit::classic::parser<sss<ParserT> > > 
    {
        typedef sss<ParserT>                    self_t;
        typedef  boost::spirit::classic::unary_parser_category           parser_category_t;
        typedef sss_parser_gen                  parser_generator_t;
        typedef boost::spirit::classic::unary<ParserT, boost::spirit::classic::parser<self_t> > base_t;

        sss(ParserT const& p)
        : base_t(p) {}

        template <typename ScannerT>
        typename boost::spirit::classic::parser_result<self_t, ScannerT>::type
        parse(ScannerT const& scan) const
        {
            typedef typename boost::spirit::classic::parser_result<self_t, ScannerT>::type result_t;
            return impl::drt_parser_parse<result_t>
                //(this->subject(), scan, scan);
                (*this, scan, scan);
        }

        const char* MyName() const { return "sss"; }

        template <typename ScannerT>
        inline void
        deriv_action_before_parse(
            ScannerT const& scan) const
        {
            prevSize = var::scopeSuffixSize;
            var::scopeSuffixSize = 0;
        }

        template <typename ScannerT>
        inline void
        deriv_action_after_parse(
            ScannerT const& scan) const
        {
            var::scopeSuffixSize = prevSize;
        }

    private:
        mutable std::size_t prevSize;
    };

    //////////////////////////////////
    const drt_parser_gen<sss> sss_d = drt_parser_gen<sss>();

}} // namespace cnome { namespace directive {

#endif  // DIRECTIVE_SSS_H
